﻿app.controller("HomeController", function ($scope, $http, LoginFactory) {
    $scope.isLoggedIn = LoginFactory.loggedIn();
    $scope.artistArtArray = [];

    $scope.login = function () {
        LoginFactory.login($scope.username, $scope.password).then(function(name) {
            $scope.name = name;
            $scope.isLoggedIn = true;
            
            //alert($scope.name + " from controller");
        })
    }

    $scope.logout = function () {
        LoginFactory.logout();
        $scope.isLoggedIn = false;
    }

    $scope.getArt = function () {
        $http.get('/api/apiArtistArt').success(function (data, status, headers, config) {
            alert("Connected");
            for (var x in data) {
                var inComing = data[x];
                $scope.artistArtArray.push(inComing);
            }
        }).error(function (data, status, headers, config) {
            alert(data + " " + status);
        });
    }

    $scope.getArt();
})
